<?php
// +----------------------------------------------------------------------
// | Jqcms [ Avenue to Jane ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017 http://jqcms.net All rights reserved.
// +----------------------------------------------------------------------
// | Author: hyacinth <845077398@qq.com>
// +----------------------------------------------------------------------
namespace Admin\Controller;
use Think\Controller;

class LoginController extends Controller {
    
//管理员登陆
    public function index(){
        
        if(IS_POST){
            
            $verify = I('verify');
            if(!check_verify($verify)){
                $this->error("验证码错误！");
            }
            $admin = D('Admin');
            $isadmin = $admin->loginAdmin();
            if($isadmin){
                $this->success('登陆成功!',U('Admin/index'));
                session('uid',$isadmin['id']);
                session('name',$isadmin['name']);
                cookie('uid',$isadmin['id']);
                cookie('name',$isadmin['name']);
            }else {
                $this->error('用户名密码错误!',U('Admin/Login'));
            }
            
        }else {
            $this->display();
        }
        
    }
    //退出登录
    public function outlogin(){
    
        session(null);
        if(!session('?name')){
            $this->success('成功退出!',U('Admin/Login'));
        }else{
            $this->error('退出失败!');
        }
    
    }
    //生成验证码
    public function verify_c(){
    
        $Verify = new \Think\Verify();
        $Verify->fontSize = 18;
        $Verify->length   = 4;
        $Verify->useNoise = false;
        $Verify->codeSet = '0123456789';
        $Verify->imageW = 130;
        $Verify->imageH = 50;
        //$Verify->expire = 600;
        $Verify->entry();
    
    }
    
    
    
}